package com.wsl.Controller;

import com.lww.springcloudapi.pojo.TabHallBusiness;
import com.lww.springcloudapi.result.LayuiEntity;
import com.wsl.service.BusinessService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller

public class BusinessController {
    @Autowired
    private BusinessService businessService;

    @RequestMapping("/selectbusiness")
    @CrossOrigin
    @ResponseBody
    public LayuiEntity toLogin(){
        LayuiEntity layuiEntity=new LayuiEntity();
        layuiEntity.setCode("200");
        layuiEntity.setData(businessService.selectbusiness());
        layuiEntity.setCount(businessService.selectcount());
        layuiEntity.setMsg("查询成功！");
        try {

        }catch (Exception e){
            layuiEntity.setCode("500");
            layuiEntity.setMsg("查询失败！");
        }
        return layuiEntity;
    }
    @RequestMapping("/upbusiness")
    @ResponseBody
    public int toLogin(TabHallBusiness tabHallBusiness){
        return businessService.upbusiness(tabHallBusiness);
    }
    @RequestMapping("/selectbyidbusiness")
    @ResponseBody
    public TabHallBusiness selectbyidbusiness(@RequestParam("id") Integer id){
        return businessService.selectbyidbusiness(id);
    }
    @RequestMapping("/addbusiness")
    @ResponseBody
    public int addbusiness(TabHallBusiness tabHallBusiness){
        return businessService.addbusiness(tabHallBusiness);
    }
    @RequestMapping("/delbyidbusiness")
    @ResponseBody
    public int delbyidbusiness(@RequestParam("id") Integer id){
        return businessService.delbyidbusiness(id);
    }
}
